<?php
namespace app\thread\controller;
use app\thread\model\Thread;
use think\Session;
class Post{
    function index(){
        return view('post');
    }
    function post(){
        $title=input('title');
        $context=input('context');
        $m_id=input('m_id');
        $name=Session::get('user');
        $post_thread=new Thread();
        $first_time=date("Y-m-d H:i:s");
        $last_time=$first_time;
        $post_thread->data([
            'title'=>$title,
            'context'=>$context,
            'm_id'=>$m_id,
            'name'=>$name,
            'first_time'=>$first_time,
            'last_time'=>$last_time
        ]);
        if ($post_thread->save()){
            return '提交成功！';
        }else{
            return $post_thread->getError();
        }

    }
}